package com.alcohol.auth.server.support.grant.password;

import com.alcohol.auth.server.constant.AuthGrantType;
import com.alcohol.auth.server.support.grant.base.BaseAuthenticationToken;
import lombok.Getter;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.core.AuthorizationGrantType;

import java.util.Map;
import java.util.Set;

/**
 * 密码认证令牌
 * @author LiXinYu
 * @date 2025/11/8
 */
public class PasswordAuthenticationToken extends BaseAuthenticationToken {

    /* 用户名 */
    @Getter
    private final String username;
    /* 密码 */
    @Getter
    private final String password;

    /**
     * OAuth2-密码认证对象
     *
     * @param clientPrincipal        客户端认证信息
     * @param scopes                 认证作用域
     * @param additionalParameters   扩展信息
     */
    public PasswordAuthenticationToken(String username, String password, Authentication clientPrincipal,
                                       Set<String> scopes, Map<String, Object> additionalParameters) {
        super(new AuthorizationGrantType(AuthGrantType.PASSWORD.getGrantType()), clientPrincipal, scopes, additionalParameters);
        this.username = username;
        this.password = password;
    }
}
